package com.matrix.draft.sockettest.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.logging.LoggingHandler;

/**
 * NioSocketChannel初始化器
 * 用于将Socket封装成NioSocketChannel
 */
public class HttpSocketInitializer extends ChannelInitializer<NioSocketChannel> {
    @Override
    protected void initChannel(NioSocketChannel ch) throws Exception {
        ch.pipeline().addLast("loggingHandler",new LoggingHandler());
        ch.pipeline().addLast("CodecHandler",new HttpServerCodec());
        ch.pipeline().addLast("MainHandler",new HttpServerHandler());
    }
}
